home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 37 / CD Expert nº 37.iso / LastCall / lastcall.exe / stuff / lastcall.dxr / 00006_Bottle Being Dragged.ls < prev    next >
Encoding:
Text File  |  2000-03-27  |  12.8 KB  |  434 lines

  1. property pOrigMember, pDraggingMember, pPourableMember, pPourSound, pSpr, pNumPourPositions, pIngredient, pLiquidColor, pTilt, pOrigSprite, pLastPourDest
  2. global gDraggingBottle, gMatrixMode, gQuickPlayMode, gDemoVersion
  3.  
  4. on beginSprite me
  5.   pSpr = sprite(me.spriteNum)
  6.   pSpr.locZ = 125
  7. end
  8.  
  9. on endSprite me
  10.   pSpr.locZ = me.spriteNum
  11.   removeFromActorList(pSpr)
  12. end
  13.  
  14. on mPickUpBottle me, bottleSprite, keepOrigVisible, liquidColor, ingredient, pourSound, pickupSound, cursorOffset
  15.   global gLastIngredient, gSoundFXchan
  16.   hideToolTip()
  17.   storeLastIngredient(ingredient)
  18.   gDraggingBottle = me.spriteNum
  19.   addToActorList(pSpr)
  20.   if inBonusMode() then
  21.     playBonusSound(gSoundFXchan, "BRA_X03")
  22.   else
  23.     if voidp(pickupSound) then
  24.       clickSound()
  25.     else
  26.       soundFX(pickupSound, 0, 0)
  27.     end if
  28.   end if
  29.   hideCursor()
  30.   pPourSound = pourSound
  31.   if voidp(liquidColor) then
  32.     pLiquidColor = red()
  33.   else
  34.     pLiquidColor = liquidColor
  35.   end if
  36.   pIngredient = ingredient
  37.   pNumPourPositions = 6
  38.   pOrigSprite = bottleSprite
  39.   pOrigMember = bottleSprite.member
  40.   pTilt = bottleSprite.pTilt
  41.   setPourableBottle(me, 0)
  42.   if not keepOrigVisible then
  43.     bottleSprite.visible = 0
  44.   end if
  45.   switchMember(me, pDraggingMember)
  46.   if not ilk(cursorOffset, #point) then
  47.     cursorOffset = the mouseLoc
  48.   end if
  49.   placeCursor(cursorOffset)
  50.   pSpr.loc = cursorOffset
  51.   pSpr.visible = 1
  52.   pSpr.member.useAlpha = 1
  53.   resetPourMeter()
  54.   updateStage()
  55. end
  56.  
  57. on setPourableBottle me, toggle
  58.   if toggle then
  59.     if pTilt = #right then
  60.       pTilt = #left
  61.     else
  62.       pTilt = #right
  63.     end if
  64.   end if
  65.   dragThang = 1
  66.   pourThang = 4
  67.   pDraggingMember = sendSprite(pOrigSprite, #mSetNewTilt, pTilt)
  68.   if voidp(pDraggingMember) then
  69.     leftBottlesOffset = 10
  70.     if pTilt = #right then
  71.       pDraggingMember = nextMember(pOrigMember, dragThang)
  72.       pPourableMember = nextMember(pOrigMember, pourThang)
  73.     else
  74.       pDraggingMember = nextMember(pOrigMember, dragThang + leftBottlesOffset)
  75.       pPourableMember = nextMember(pOrigMember, pourThang + leftBottlesOffset)
  76.     end if
  77.   else
  78.     pPourableMember = nextMember(pDraggingMember, pourThang - dragThang)
  79.   end if
  80. end
  81.  
  82. on mReplaceIt me
  83.   if not gDraggingBottle then
  84.     exit
  85.   end if
  86.   pSpr.visible = 0
  87.   removeFromActorList(pSpr)
  88.   gDraggingBottle = 0
  89.   pIngredient = VOID
  90.   resetCursor()
  91.   sendSprite(pOrigSprite, #mReplaceIt)
  92. end
  93.  
  94. on tiltBottle me
  95.   switchMember(me, pPourableMember)
  96.   if gMatrixMode or (commandOrControlDown() and the shiftDown) then
  97.     pSpr.trails = 1
  98.     soundFX2("wah-wah")
  99.   else
  100.   end if
  101.   repeat with X = 1 to pNumPourPositions
  102.     if gDemoVersion or gQuickPlayMode or (the shiftDown and not commandOrControlDown()) then
  103.       pSpr.memberNum = pSpr.memberNum + pNumPourPositions
  104.       updateStage()
  105.       exit repeat
  106.       next repeat
  107.     end if
  108.     pSpr.memberNum = pSpr.memberNum + 1
  109.     updateStage()
  110.   end repeat
  111. end
  112.  
  113. on untiltBottle me
  114.   pSpr.trails = 0
  115.   if gMatrixMode then
  116.   end if
  117.   quickDip = the shiftDown and not commandOrControlDown()
  118.   repeat with X = 1 to pNumPourPositions
  119.     if gDemoVersion or gQuickPlayMode or quickDip then
  120.       pSpr.memberNum = pSpr.memberNum - pNumPourPositions
  121.       exit repeat
  122.     else
  123.       pSpr.memberNum = pSpr.memberNum - 1
  124.     end if
  125.     updateStage()
  126.   end repeat
  127.   switchMember(me, pPourableMember)
  128. end
  129.  
  130. on pour me, ingredient, receiveSound
  131.   global gBarGlassSprites, gMachineSpeed, gPourThrottleRate, gEvenPouring, gLastVessel
  132.   if inBonusMode() then
  133.     playBonusSoundDrop()
  134.     sendSprite(the clickOn, #mDropIngredient, pIngredient)
  135.     exit
  136.   end if
  137.   if not voidp(receiveSound) then
  138.     pPourSound = receiveSound
  139.   end if
  140.   dest = overPourableItem(me)
  141.   if dest <> pLastPourDest then
  142.     pLastPourDest = dest
  143.     resetPourMeter()
  144.   end if
  145.   if dest then
  146.     if isSodaIngredient(ingredient) then
  147.       if sendSprite(dest, #mHasIce) then
  148.         pPourSound = "gun_into_ice"
  149.       else
  150.         pPourSound = "gun_into_glass"
  151.       end if
  152.     else
  153.       if isPowder(ingredient) then
  154.         pPourSound = "sugar_sound"
  155.       else
  156.         if voidp(pPourSound) then
  157.           if sendSprite(dest, #mHasIce) then
  158.             pPourSound = "water_into_mglass"
  159.           else
  160.             pPourSound = "water_into_mglass_wice"
  161.           end if
  162.         end if
  163.       end if
  164.     end if
  165.   end if
  166.   tiltBottle(me)
  167.   if getOne(gBarGlassSprites, dest) then
  168.     if sprite(barSlotToSprite(glassSpriteToBarSlot(dest))).pDrinksBeenServed then
  169.       chillYouveServedDrink()
  170.       exit
  171.     end if
  172.     gLastVessel = glassSpriteToBarSlot(dest)
  173.   end if
  174.   if ingredient <> #ice then
  175.     soundFX(pPourSound, 1, 0)
  176.   end if
  177.   extraLiquid = 0
  178.   startPour = nowTicks()
  179.   totalPoured = 0
  180.   dest = overPourableItem(me)
  181.   if getOne(gBarGlassSprites, dest) then
  182.     makePatronActive(glassSpriteToBarSlot(dest))
  183.     gLastVessel = glassSpriteToBarSlot(dest)
  184.     updateStage()
  185.   end if
  186.   repeat while the stillDown
  187.     dest = overPourableItem(me)
  188.     if dest then
  189.       lastDest = sprite(dest)
  190.       basePourSpeed = getPourSpeed(pIngredient)
  191.       if the optionDown then
  192.         multiplier = 2.5
  193.       else
  194.         if the controlDown then
  195.           multiplier = 0.5
  196.         else
  197.           if the commandDown then
  198.             multiplier = 5
  199.           else
  200.             multiplier = 1
  201.           end if
  202.         end if
  203.       end if
  204.       extraLiquid = max(0, extraLiquid + multiplier - 1)
  205.       if gEvenPouring then
  206.         numIncrements = ticksSince(startPour) / gPourThrottleRate
  207.       else
  208.         numIncrements = ticksSince(startPour) / float(gPourThrottleRate)
  209.       end if
  210.       shouldHaveBeenPoured = (numIncrements + extraLiquid) * basePourSpeed
  211.       missingLiquid = shouldHaveBeenPoured - totalPoured + (multiplier * basePourSpeed)
  212.       slowStart = 0.25
  213.       if totalPoured < slowStart then
  214.         missingLiquid = min(missingLiquid, slowStart / 2)
  215.       end if
  216.       if not gEvenPouring then
  217.         if missingLiquid >= (basePourSpeed * 4) then
  218.           gMachineSpeed = #verySlow
  219.         else
  220.           if missingLiquid >= (basePourSpeed * 3) then
  221.             gMachineSpeed = #slow
  222.           else
  223.             if missingLiquid > (basePourSpeed * 2) then
  224.               gMachineSpeed = #medium
  225.             else
  226.               gMachineSpeed = #fast
  227.             end if
  228.           end if
  229.         end if
  230.       end if
  231.       if the shiftDown then
  232.         POURSPEED = basePourSpeed * multiplier
  233.       else
  234.         if missingLiquid < basePourSpeed then
  235.           POURSPEED = max(0, missingLiquid * multiplier)
  236.         else
  237.           POURSPEED = min(missingLiquid * multiplier, basePourSpeed * 3)
  238.         end if
  239.       end if
  240.       contents = sendSprite(dest, #mIsHoldingVolume)
  241.       if contents < sprite(dest).pCapacity then
  242.         if getOne([#mixingGlass, #shaker, #blender], pIngredient) then
  243.           vessel = sprite([#mixingGlass: 53, #shaker: 51, #blender: 49][ingredient])
  244.           amountLeft = sendSprite(vessel, #mIsHoldingLiquid)
  245.           if amountLeft < POURSPEED then
  246.             POURSPEED = amountLeft
  247.           end if
  248.         end if
  249.         if (contents + POURSPEED) > sprite(dest).pCapacity then
  250.           POURSPEED = sprite(dest).pCapacity - contents
  251.         end if
  252.         sendSprite(dest, #mFill, pIngredient, pLiquidColor)
  253.         runPourMeter(POURSPEED)
  254.         totalPoured = totalPoured + POURSPEED
  255.         Quantity = readPourMeter()
  256.         if objectp(lastDest) then
  257.           case ingredient of
  258.             #mixingGlass, #shaker, #blender:
  259.               gLastVessel = ingredient
  260.               vessel = sprite([#mixingGlass: 53, #shaker: 51, #blender: 49][ingredient])
  261.               readFrom = vessel.pContents
  262.               vessel.pLastDest = lastDest
  263.               liquorQuantity = sendSprite(vessel, #mIsHoldingPourable)
  264.               if liquorQuantity <= 0 then
  265.                 alertBeep()
  266.                 exit repeat
  267.               end if
  268.               lastDest.pContents[pIngredient] = 1
  269.               numIngredients = count(readFrom)
  270.               repeat with X = 1 to numIngredients
  271.                 subIngredient = getPropAt(readFrom, X)
  272.                 if subIngredient = #ice then
  273.                   subIngredient = #iceNonGlass
  274.                 end if
  275.                 if subIngredient <> #Slush then
  276.                   if voidp(lastDest.pContents[subIngredient]) then
  277.                     lastDest.pContents[subIngredient] = 0
  278.                   end if
  279.                 end if
  280.               end repeat
  281.               repeat with X = numIngredients down to 1
  282.                 subIngredient = getPropAt(readFrom, X)
  283.                 case subIngredient of
  284.                   #ice:
  285.                     if voidp(vessel.pContents[#ice]) then
  286.                       nothing()
  287.                     else
  288.                       lastDest.pContents[#iceNonGlass] = vessel.pContents[#ice]
  289.                     end if
  290.                   #blend, #shake, #stir, #Muddle:
  291.                     lastDest.pContents[subIngredient] = 1
  292.                     deleteProp(vessel.pContents, subIngredient)
  293.                   #olive, #lemonWedge, #orangeWedge, #limeWedge, #cherry, #limetwist, #lemontwist:
  294.                     lastDest.pContents[subIngredient] = vessel.pContents[subIngredient]
  295.                     deleteProp(vessel.pContents, subIngredient)
  296.                   otherwise:
  297.                     if subIngredient = #Slush then
  298.                       if liquorQuantity <> vessel.pContents[#Slush] then
  299.                         next repeat
  300.                       end if
  301.                     end if
  302.                     if voidp(lastDest.pContents[subIngredient]) then
  303.                       lastDest.pContents[subIngredient] = 0
  304.                     end if
  305.                     if liquorQuantity > 0 then
  306.                       transfer = readFrom[X] * min(1.0, float(POURSPEED) / liquorQuantity)
  307.                     else
  308.                       exit repeat
  309.                     end if
  310.                     lastDest.pContents[subIngredient] = lastDest.pContents[subIngredient] + transfer
  311.                     vessel.pContents[X] = max(0, vessel.pContents[X] - transfer)
  312.                     if vessel.pContents[X] <= 0 then
  313.                       deleteAt(vessel.pContents, X)
  314.                     end if
  315.                     liquorQuantity = sendSprite(vessel, #mIsHoldingPourable)
  316.                     if liquorQuantity <= 0 then
  317.                       sendSprite(vessel, #mEmptyGlass)
  318.                     end if
  319.                 end case
  320.               end repeat
  321.               sendSprite(vessel.pGlassMask, #mUpdateLiquidLevel, vessel)
  322.             otherwise:
  323.               if voidp(lastDest.pContents[ingredient]) then
  324.                 lastDest.pContents[ingredient] = 0
  325.               end if
  326.               lastDest.pContents[ingredient] = lastDest.pContents[ingredient] + POURSPEED
  327.           end case
  328.         end if
  329.         if objectp(lastDest) then
  330.           lastDest.pContentString = EMPTY
  331.           newString = buildVesselContentList(lastDest, lastDest.pGlassType, " The Glass is Empty")
  332.           showDrinkContents(ingredient, newString, Quantity)
  333.         end if
  334.       else
  335.         stopSoundFX()
  336.         alertBeep()
  337.         exit repeat
  338.       end if
  339.       updateStage()
  340.       checkElapsedTime()
  341.       if the shiftDown then
  342.         exit repeat
  343.       end if
  344.       next repeat
  345.     end if
  346.     exit repeat
  347.   end repeat
  348.   if not voidp(vessel) then
  349.     vessel.pContentString = VOID
  350.   end if
  351.   stopSoundFX()
  352.   untiltBottle(me)
  353. end
  354.  
  355. on mFlip me
  356.   if not draggingBottleThang() then
  357.     exit
  358.   end if
  359.   if pTilt = #right then
  360.     startFrom = 3
  361.     endAt = 10
  362.     startFrom2 = 20
  363.     endAt2 = 13
  364.   else
  365.     startFrom = 13
  366.     endAt = 20
  367.     startFrom2 = 10
  368.     endAt2 = 3
  369.   end if
  370.   repeat with X = startFrom to endAt
  371.     pSpr.member = nextMember(pOrigMember, X)
  372.     updateStage()
  373.   end repeat
  374.   repeat with X = startFrom2 down to endAt2
  375.     pSpr.member = nextMember(pOrigMember, X)
  376.     updateStage()
  377.   end repeat
  378.   setPourableBottle(me, 1)
  379.   updateStage()
  380. end
  381.  
  382. on switchMember me, newMember
  383.   if pSpr.member <> newMember then
  384.     pSpr.member = newMember
  385.   end if
  386. end
  387.  
  388. on stepFrame me
  389.   if not gMatrixMode then
  390.     pSpr.loc = the mouseLoc
  391.   end if
  392. end
  393.  
  394. on exitFrame me
  395.   if draggingBottleThang() then
  396.     if overPourableItem(me) then
  397.       switchMember(me, pPourableMember)
  398.     else
  399.       if pIngredient = #shaker then
  400.         nothing()
  401.       else
  402.         switchMember(me, pDraggingMember)
  403.       end if
  404.     end if
  405.     pSpr.loc = the mouseLoc
  406.     if pTilt = #right then
  407.       if pSpr.rect.left < -20 then
  408.         setPourableBottle(me, 1)
  409.         switchMember(me, pDraggingMember)
  410.       end if
  411.     else
  412.       if pSpr.rect.right > 665 then
  413.         setPourableBottle(me, 1)
  414.         switchMember(me, pDraggingMember)
  415.       end if
  416.     end if
  417.     updateStage()
  418.   end if
  419. end
  420.  
  421. on overPourableItem me
  422.   global gPourableItemsList
  423.   repeat with X in gPourableItemsList
  424.     if sendSprite(X, #mOverItem, pSpr, the mouseLoc, pIngredient) and (X <> pOrigSprite) then
  425.       if (X = 89) or (X = 85) or (X = 81) then
  426.         return X - 2
  427.         next repeat
  428.       end if
  429.       return X
  430.     end if
  431.   end repeat
  432.   return 0
  433. end
  434.